package cc.zy.base.hr.controller;

import cc.zy.base.common.controller.BaseController;
import cc.zy.base.common.entity.FebsConstant;
import cc.zy.base.common.entity.FebsResponse;
import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.common.utils.FebsUtil;
import cc.zy.base.hr.entity.Staff;
import cc.zy.base.hr.service.IStaffService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 员工
 * Controller
 *
 * @author Jiangjinlin
 * @date 2021-01-18 10:51:13
 */
@Slf4j
@Validated
@Controller
@RequiredArgsConstructor
@RequestMapping("staff")
public class StaffSelectController extends BaseController {

    private static final String regex = "^[\u4e00-\u9fa5]{2,4}$";

    @Resource
    private final IStaffService staffService;

    /**
     * @Author: DYQ
     * @Description: 分页
     * @DateTime: 2022/3/9 10:30
     * @Params: cc.zy.base.common.entity.FebsResponse
     * @Return [request, college]
     */
    @GetMapping("golist")
    @ResponseBody
    public FebsResponse collegeList(QueryRequest request, Staff staff) {

        log.debug("前台传来的对象是：" + staff);
        Map<String, Object> dataTable = getDataTable(staffService.findStaff(request, staff));
        System.out.println(dataTable);

        return new FebsResponse().success().data(dataTable);

    }

    /**
     * @Author: WBR
     * @Description: 根据标签查员工
     * @DateTime: 2022/3/11 16:47
     * @Params: [request, staff]
     * @Return cc.zy.base.common.entity.FebsResponse
     */
    @ResponseBody
    @GetMapping("ListByLabel")
    public FebsResponse SelectStaffListByLabel(QueryRequest request, Staff staff) {

        log.debug("前台传来的对象是：" + staff);
        Map<String, Object> dataTable = getDataTable(staffService.findStaffByLabel(request, staff));
        return new FebsResponse().success().data(dataTable);

    }

    /**
     * @Author: WBR
     * @Description: 查标签id
     * @DateTime: 2022/3/11 16:46
     * @Params: []
     * @Return cc.zy.base.common.entity.FebsResponse
     */
    @ResponseBody
    @GetMapping("staffSelect")
    public FebsResponse findStaffForSelect() {
        List<Staff> staffList = staffService.findStaffForSelect();
        return new FebsResponse().success().data(staffList);
    }

}